#include "MC.h"

#include "structure.h"

void ReliefSList(slnode* head)
{
	if(head == NULL)
		return;
	if(head->next != NULL)
		ReliefSList(head);
	Kfree(NULL,head);
}
void TNRemoveSingle(tnode* snode)
{
	if(snode->mark != NULL)
		Kfree(NULL,snode->mark);
	Kfree(NULL,snode);
}

void TNRemoveAll(tnode* snode)
{
	TNRemove(snode);
//DeepFind
	stack path;
	unsigned int base[256];
	StackInit(&path,base,sizeof(tnode*),256);
	StackPush(&path,snode);
	tnode* pointer = snode;
	while(StackEmpty(&path) != 0)
	{
	//on explore
		if(pointer != NULL)
		{
			if(pointer->son != NULL)
			{
				StackPush(&path,&pointer);
				pointer = pointer->son;
			}
			else
			{
				tnode* Reli = pointer;
				pointer = pointer->bro;
				TNRemoveSingle(Reli);
				
			}
		}
		else
		{
			StackPop(&path,&pointer);
			tnode* Reli = pointer;
			pointer = pointer->bro;
				TNRemoveSingle(Reli);
		}
	}
}
